package com.peng.mapper;

import com.peng.pojo.Article;
import com.peng.pojo.OpenCourse;
import com.peng.pojo.User;
import com.peng.pojo.WelfareCastle;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TeacherMapper {
    /**
     * 查询教师列表，并且可以通过用户名查询
     *
     * @param username
     * @return
     */
    List<User> selectTeacherAll(@Param("username") String username);

    /**
     * 添加教师
     *
     * @param user
     * @return
     */
    int addTeacher(User user);

    /**
     * 修改教师用户状态，
     *
     * @param status 1为解冻，2为冷冻 3为假删除
     * @param id     用户集合
     * @return
     */
    int updateTeacherStatus(@Param("status") int status, @Param("id") Integer... id);

    /**
     * 删除教师用户
     *
     * @param id
     * @return
     */
    int deleteTeacherById(@Param("id") Integer... id);

    @Select("select * from tb_article where publisher_id = #{publisher_id}")
    List<Article> selectArticleBypublisherId(int publishId);

    @Select("select * from tb_open_course where teacher_id = #{teacherId}")
    List<OpenCourse> selectOpenCourseBypublisherId(int teacherId);

    @Select("select * from tb_welfare_castle where teacher_id = #{teacherId}")
    List<WelfareCastle> selectWelfareCastleByWelfareCastleId(int teacherId);
}
